home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / os2tools / bnklysrc / b_passwo.c < prev    next >
C/C++ Source or Header  |  1989-03-04  |  7KB  |  162 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software <no-Inc>                   */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          No-Cost<no-tm> Software.                       */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello  */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*                      BinkleyTerm Password Processor                      */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*    For complete  details  of the licensing restrictions, please refer    */
  17. /*    to the License  agreement,  which  is published in its entirety in    */
  18. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.210.    */
  19. /*                                                                          */
  20. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  21. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  22. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  23. /*    NOT HAVE THESE FILES,  YOU SHOULD  IMMEDIATELY CONTACT THE AUTHORS    */
  24. /*    AT THE  ADDRESSES LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO    */
  25. /*    USE   THIS  FILE  WITHOUT  HAVING   ACCEPTED  THE  TERMS  OF   THE    */
  26. /*    BINKLEYTERM  LICENSING AGREEMENT,  OR SUCH OTHER  AGREEMENT AS YOU    */
  27. /*    ARE ABLE TO REACH WITH THE AUTHORS.                                   */
  28. /*                                                                          */
  29. /*                                                                          */
  30. /*    The Authors can be reached at the following addresses:                */
  31. /*                                                                          */
  32. /*    Robert C. Hartman                      Vincent E. Perriello           */
  33. /*    Spark Software                         VEP Software                   */
  34. /*    427-3 Amherst Street                   111 Carroll Street             */
  35. /*    CS2032, Suite 232                      Naugatuck, CT 06770            */
  36. /*    Nashua, NH 03061                                                      */
  37. /*                                                                          */
  38. /*    FidoNet 1:132/101                      FidoNet 1:141/491              */
  39. /*    Data    (603) 888-8179                 Data    (203) 729-7569         */
  40. /*                                                                          */
  41. /*    Please feel free to contact us at any time to share your comments     */
  42. /*    about our software and/or licensing policies.                         */
  43. /*                                                                          */
  44. /*                                                                          */
  45. /*  This module is based largely on a similar module in OPUS-CBCS V1.03b.   */
  46. /*  The original work is (C) Copyright 1987, Wynn Wagner III. The original  */
  47. /*  author has graciously allowed us to use his code in this work.          */
  48. /*                                                                          */
  49. /*--------------------------------------------------------------------------*/
  50.  
  51. #include <signal.h>
  52. #include <ctype.h>
  53. #include <conio.h>
  54. #include <string.h>
  55.  
  56. #define WAZOO_SECTION
  57. #include "com.h"
  58. #include "xfer.h"
  59. #include "zmodem.h"
  60. #include "keybd.h"
  61. #include "sbuf.h"
  62. #include "sched.h"
  63. #include "externs.h"
  64. #include "prototyp.h"
  65.  
  66. static char *snitty_message = "Sorry, Charlie.";
  67. static char *strnpbk (char *, int);
  68.  
  69. /*--------------------------------------------------------------------------*/
  70. /* N PASSWORD                                                               */
  71. /*--------------------------------------------------------------------------*/
  72. int n_password (theirs, ours)
  73. char *theirs;
  74. char *ours;
  75. {
  76.    if ((ours != NULL) && (ours[0]))
  77.       {
  78.       if ((theirs != NULL) && (theirs[0]))
  79.          {
  80.          strnpbk (theirs, 8);           /* Get rid of trailing blanks */
  81.          strnpbk (ours, 8);
  82.  
  83.          if (!strnicmp (theirs, ours, 8))
  84.             {
  85.             status_line ("*Password-protected session");
  86.             return 0;
  87.             }
  88.          }
  89.                 
  90.       status_line ("!Pwd Err (%d:%d/%d): %s/%s",
  91.                     remote_zone,
  92.                     remote_net,
  93.                     remote_node,
  94.                     theirs,
  95.                     ours
  96.                   );
  97.  
  98.       SENDCHARS (snitty_message, strlen (snitty_message), 0);
  99.  
  100.       while (!OUT_EMPTY () && CARRIER)
  101.          time_release ();
  102.  
  103.       return 1;
  104.       }
  105.    return 0;
  106. }
  107.  
  108.  
  109. /*--------------------------------------------------------------------------*/
  110. /* N GET PASSWORD                                                           */
  111. /* Find the nodelist entry for this system and point remote_password at     */
  112. /* its password if any                                                      */
  113. /*--------------------------------------------------------------------------*/
  114. int n_getpassword (zone, net, node)
  115. int zone, net, node;
  116. {
  117.    extern char *remote_password;
  118.    extern struct _newnode newnodedes;            /* desc. of node            */
  119.    
  120.    remote_password = NULL;                       /* Default to no password   */
  121.    newnodedes.Password[0] = '\0';
  122.  
  123.    if (!nodefind (zone, net, node, 0))           /* find the node in the list */
  124.       {
  125.       remote_password = NULL;
  126.       return (0);                                /* return failure if can't  */
  127.       }
  128.  
  129.    if (newnodedes.Password[0] != '\0')           /* If anything there,       */
  130.       {
  131.       remote_password = &newnodedes.Password[0]; /* Point at it              */
  132.       return (1);                                /* Successful attempt       */
  133.       }
  134.    else
  135.       {
  136.       /* No password involved */
  137.       return (0);
  138.       }
  139. }
  140.  
  141. /*
  142.  * Strip all trailing blanks from a record.
  143.  *
  144.  */
  145.  
  146. static char *strnpbk (string, n)
  147. register char *string;
  148. register int n;
  149. {
  150.    string += n;                                 /* point past end of string */
  151.    while (n--)                                  /* now keep count */
  152.       {
  153.       if (*--string)                            /* if there's a character   */
  154.          {
  155.      if (*string != ' ')                    /* if not a blank, we exit  */
  156.         break;
  157.      *string = '\0';                        /* if blank, terminate here */
  158.      }
  159.       }
  160.    return string;
  161. }
  162.